/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ListRendererEmpleados.java
 *
 * Created on 10/04/2011, 11:54:56 PM
 */

package frontera.interfaz.listRenderer;

import entidad.Empleado;
import java.awt.Color;
import java.awt.Component;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

/**
 *
 * @author Sebastian
 */
public class ListRendererEmpleados extends javax.swing.JPanel implements ListCellRenderer {

    /** Creates new form ListRendererEmpleados */
    public ListRendererEmpleados() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        labelNombre = new javax.swing.JLabel();
        labelCedula = new javax.swing.JLabel();
        labelProfesion = new javax.swing.JLabel();
        labelEstado = new javax.swing.JLabel();
        labelPorcentajeSBasico = new javax.swing.JLabel();
        labelCargo = new javax.swing.JLabel();

        setLayout(new java.awt.GridLayout(1, 0));

        labelNombre.setText("nombre");
        add(labelNombre);

        labelCedula.setText("cedula");
        add(labelCedula);

        labelProfesion.setText("profesion");
        add(labelProfesion);

        labelEstado.setText("estado");
        add(labelEstado);

        labelPorcentajeSBasico.setText("porcentajeSBasico");
        add(labelPorcentajeSBasico);

        labelCargo.setText("cargo");
        add(labelCargo);
    }// </editor-fold>//GEN-END:initComponents

    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        Empleado empleado = (Empleado)value;

        NumberFormat formatter = new DecimalFormat("#0.00");

        labelNombre.setText(empleado.getNombre());
        labelCargo.setText(empleado.getCargoAsociado().getNombre());
        labelCedula.setText(empleado.getCedula());
        labelEstado.setText(empleado.getEstado());
        labelPorcentajeSBasico.setText(formatter.format(empleado.getPorcentajeSalarioBas()));
        labelProfesion.setText(empleado.getProfesion());

        if(isSelected){
            this.setBackground(new Color(200, 200, 255));
        }
        else{
            this.setBackground(new Color(255, 255, 255));
        }

        return this;
    }


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel labelCargo;
    private javax.swing.JLabel labelCedula;
    private javax.swing.JLabel labelEstado;
    private javax.swing.JLabel labelNombre;
    private javax.swing.JLabel labelPorcentajeSBasico;
    private javax.swing.JLabel labelProfesion;
    // End of variables declaration//GEN-END:variables

}
